package cm.fw.base;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;

import org.apache.commons.beanutils.BeanUtils;

public abstract class CommonActionBean implements ActionBean {

    protected ActionBeanContext context;

    @DefaultHandler
    protected void doNoThing() {
    }

    protected CommonForm mapToBean(Class<? extends CommonForm> cls)
            throws Exception {
        CommonForm form = (CommonForm) cls.newInstance();
        BeanUtils.populate(form, context.getRequest().getParameterMap());
        return form;
    }

    @Override
    public ActionBeanContext getContext() {
        return context;
    }

    @Override
    public void setContext(ActionBeanContext context) {
        this.context = context;
    }
}
